﻿@using OBUCare.Core.Models
@using OBUCare.Web.Models
@using OBUCare.Web.Infrastructure

@{
    bool isPreveiw = (bool)ViewBag.IsPreView;
    int txtRemarkColWidth = 120;
    //if (isPreveiw)
    //{ txtRemarkColWidth = 0; }
}
@(Html.Telerik().Grid<TransferBillDetailViewModel>()
        .Name("Grid")
        .DataKeys(keys => keys.Add(c => c.ID))  
        .Sortable(sorting => sorting.SortMode(GridSortMode.SingleColumn))
        .Resizable(resizing => resizing.Columns(true))      
        .DataBinding(dataBinding => dataBinding
            .Ajax()
            .Select(ViewBag.SelectAction as string , "Transfer",ViewBag.SelectActionRouteValues ) 
                    )
        .Columns(columns =>
        {
            columns.Bound(o => o.ID).Title("序号").ClientTemplate("<#= ++index #>").Width(100).Sortable(false);
            columns.Bound(o => o.REPAIR_ORDER_NO).Width(220);
            columns.Bound(o => o.SUPPLIER).Width(100);
            columns.Bound(o => o.OBU_NO).Width(150);
            columns.Bound(o => o.SPEC_NAME).Width(120);
            columns.Bound(o => o.MAX_PRICE).Width(150);

            //if (isPreveiw)
            //{
                
            //}     
            columns.Bound(o => o.REMARK).Width(txtRemarkColWidth).Hidden(!isPreveiw);
            columns.Bound(o => o.REMARK).ClientTemplate("<input type='text' value='<#= REMARK #>' id='remark<#= ID #>' name='remark<#= ID #>' style='width:90px;'/>").Width(txtRemarkColWidth).Hidden(isPreveiw);
        }).TableHtmlAttributes(new { style = "width:900px;font-size:14px;" })
                                    .Footer(false)
                                    .Scrollable(scroll => scroll.Height(CommonStyleForUI.Grid_Height))
                                    .ClientEvents(events => events.OnDataBinding("onDataBinding"))
)


<script type="text/javascript">

    //将文本框中的备注显示到列表中
    function showRemark()
    {
        var grid = $('#Grid').data('tGrid')
        grid.hideColumn(6); //隐藏文本框列
        grid.showColumn(5); //显示初始化时隐藏的备注列

        for (i = 0; i < grid.data.length; i++) {
            var remark = $("#remark" + grid.data[i].ID).val();
            grid.data[i].REMARK = remark;
        }

        grid.dataBind(grid.data);
    }


var index = 0;
 
function onDataBinding() {
    var grid = $('#Grid').data('tGrid')
    index = (grid.currentPage - 1) * grid.pageSize;
}

</script>